<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>值绑定</title>
    <script src="./js/vue.js"></script>
</head>
<body>
    <div class="box">
        <!-- 给一个多选框设置，值绑定 -->
        <!-- <input type="checkbox" v-model="checked" true-value="你好！" false-value="hello!"><br>
        <h1>{{checked}}</h1> -->

        <!-- 实现h1中性别的动态转换，依据性别单选框 -->
        <!-- <label for="nan">男</label>
        <input type="radio" id="nan" name="sex" value="男" v-model="radioValue">
        <label for="nv">女</label>
        <input type="radio" id="nv" name="sex" value="女" v-model="radioValue">
        <h2>{{radioValue}}</h2> -->

        <!-- 需求 如何利用绑定值实现  或者说 如何利用一个radio框实现 -->
        <label for="nan">{{sexValue}}</label>
        <input type="radio" id="nan" v-bind:value="sexValue" v-model="radioValue">
        <h1>{{radioValue}}</h1>
        <button v-on:click="flag=!flag">点击切换性别</button>
    </div>
    <script>
        const vm = new Vue({
            el:'.box',
            data:{
                //设置初始值
                checked:'',//多选框的初始值为空串
                radioValue:'',
                flag:true
            },
            computed:{
                sexValue(){
                    return this.flag? '男' : '女'
                }
            }
        })
    </script>
</body>
</html>